Polymer({
    //定义卡片id，该id在card.html的<dom-module>标签中被引用。
    is: "PC-CARD-HTML-4957206830824292-01",
    properties: {
        card_title: {
            type: String,
            export: true,
            default: "学校文件"
        },
        page_size: {
            type: String,
            export: true,
            default:"6"
        },
        thumbnail: {
            type: String,
            export: true,
            default: "thumbnail.png"
        },
        target_platform: {
            type: String,
            export: true,
            default: "WEB"
        },
        param_file: {
            type: String,
            export: true,
            default: "params.xml"
        },
        page_size: {
            type: String,
            export: true,
            default: "5"
        },
        url: {
            type: String,
            export: true,
            default: "http://bgxt.sdut.edu.cn/openoa/getXxwjList.do"
        },
        type_id: {
            type: String,
            export: true,
            default: ""
        },
        news: {
            type: Array
        }
    },
    ajaxRoot: location.origin,
    ready: function() {
        var widget = this;
        var jsonData={};
        if (widget.page_size!=undefined&&widget.page_size>0){
            jsonData["num"]=widget.page_size;
        }

        if (widget.type_id!=undefined&&widget.type_id!="") {
            jsonData["root"]=widget.type_id;

        }

        $.ajax({
            async:true,
            url:widget.url,
            type: "GET",
            data:jsonData,
            dataType: 'jsonp',
            timeout: 5000,
            success:function (resp) {
                var json=resp.xxwj;
                var newsArr = [];
                $.each(json, function(idx, notice){
                    var time = notice.sendtime ? notice.sendtime.split(" ")[0] : "";
                    newsArr.push({
                        noticeTitle: notice.title,
                        sendTime: time,
                        hasAttach: "",
                        detailUrl: notice.url
                    });
                });
                widget.news = newsArr;
                widget.fire("widgetComplete");
            }
        });
    }
});
